package codeRandomThoughts.Test518零钱兑换II;

public class Solution2 {
    public int change(int amount, int[] coins) {
        //dp[j]:0-i种不同面额的硬币,可以凑成总金额为j的硬币组合数为dp[j]
        int[] dp = new int[amount + 1];

        dp[0] = 1;

        for (int i = 0; i < coins.length; i++) {
            for (int j = coins[i]; j <= amount; j++) {
                //两种来源
                //dp[i][j] dp[i][j-coins[i]]
                dp[j] = dp[j] + dp[j - coins[i]];
            }
        }

        return dp[amount];
    }
}
